var MAP_WIDTH  = 10;
var MAP_HEIGHT = 10;
var MAP_X      = 21;
var MAP_Y      = 21;
var MAP_SIZE   = (MAP_WIDTH * MAP_HEIGHT);
var MAPS       = 30;
var Tile       = new Array(MAP_SIZE);
var WorldMap   = new Array(MAPS);



WorldMap['0'] ="0000000000" 
			+"0001000000" 
			+"0000010010" 
			+"0001000000" 
			+"0100001010" 
			+"0001010000" 
			+"0000000010" 
			+"0000100000" 
			+"0101000000" 
			+"0000000000";


WorldMap['1'] ="1000000000" 
			+"0101000000" 
			+"0010010010" 
			+"0001000000" 
			+"0100101010" 
			+"0001010000" 
			+"0000001010" 
			+"0000100100" 
			+"0101000000" 
			+"0000000000";


var Map = new Array(MAP_HEIGHT);
var MapTiles = new Object();
MapTiles['0'] = '/resources/tiles/space.gif';
MapTiles['1'] = '/resources/tiles/power.gif';



function FillMap()
 { 
  var x = 0;
  var y = 0;
  var z = 0; 
  for(x = 0; x < MAP_HEIGHT; x++)
   {
    for(y = 0; y < MAP_WIDTH;)
     {      

	
      Tile[z++].src = MapTiles[Map[x][y++]];
      Tile[z++].src = MapTiles[Map[x][y++]];
     }
   }
 }
/******************************************************************************
 create the div layout for the map tiles
******************************************************************************/
function DrawMap()
 {
  var x = 0;
  var y = 0;
  var z = 0;
  for(x = 0; x < MAP_HEIGHT; x++)
   { 
    for(y = 0; y < MAP_WIDTH; y++)
     {     
      Tile[z] = document.createElement('IMG');
      Tile[z].id = z;
      Tile[z].style.zIndex = 1;
      document.getElementById('pov').appendChild(Tile[z++]);
     }
    newline = document.createElement('BR'); 
    document.getElementById('pov').appendChild(newline); 
   }
 }
/******************************************************************************
 load the specific map data
******************************************************************************/
function LoadMap(MapData)
 { 
  var x = 0;
  var y = 0;
  var z = 0; 
  for(x = 0; x < MAP_HEIGHT; x++)
   { 
    for(y = 0; y < MAP_WIDTH;)
     { 
      Map[x][y++] = MapData[z++];
      Map[x][y++] = MapData[z++];
     }
   }
 }
/******************************************************************************
 make the array that will contain map data
******************************************************************************/
function MakeMap()
 {
  var x = 0;
  for(x = 0; x < MAP_HEIGHT; x++)
   { Map[x] = new Array(MAP_WIDTH); }
 }

/*
function ClearAvatarFromMap(mapIndex, Avatar)
 { 
	document.getElementById('pov').removeChild(Avatar);
 }
 */